<?php
// +----------------------------------------------------------------------
// | KITEGO-Admin「开箱即用」「人人全栈」
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2024 https://www.kitego.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed KITEGO并不是自由软件，未经许可不能去掉KITEGO相关版权
// +----------------------------------------------------------------------
// | Author: KITEGO Team <bd@kitego.cn>
// +----------------------------------------------------------------------

namespace app\dao\setting;

use app\dao\BaseDao;
use app\model\setting\SystemRole;
use think\db\exception\DbException;

class SystemRoleDao extends BaseDao
{
    /**
     * 设置模型
     * @return string
     */
    protected function setModel(): string
    {
        return SystemRole::class;
    }

    /**
     * 角色列表
     * @param array $where
     * @param int $page
     * @param int $listRows
     * @return array
     * @throws DbException
     */
    public function listSystemRole(array $where = [], int $page = 1, int $listRows = 10): array
    {
        $listRows = [
            'query' => [], // url额外参数
            'fragment' => '', // url锚点
            'var_page' => 'page', // 分页变量
            'list_rows' => $listRows, // 每页数量
            'page' => $page // 第几页
        ];
        return $this->search($where)->order("sort desc, id asc")->paginate($listRows)->toArray();
    }
}
